#ifndef TASKMANAGER_H
#define TASKMANAGER_H

#include "Network/Network.h"
#include "NetworkTypes/NetworkTypes.h"

#include <QObject>


class TaskManager : public QObject
{
    Q_OBJECT
public:

    TaskManager()=default;
    TaskManager(NetworkManager* manager);

    BatchCheckInResponse* BatchCheckIn(const QString& factoryNo,const QString& eventUser,const QString& machineNo,const QString& batch,const QList<BatchCheckInPcuInfo>& pcuInfo);
    BatchCheckOutResponse* BatchCheckOut(const QString& factoryNo,const QString& eventUser,const QString& machineNo,const QString& batch,const QList<BatchCheckOutPcuInfo>& pcuInfo);
    HeartbeatDetectionResponse* HeartbeatDetetion(const QString& factoryNo,const QString& eventUser,const QString& machineNo,const QString& status);
    MatchProcParamCollectResponse* MatchProcParamCollectPost(const QString& factoryNo,const QString& eventUser,const QString& machineNo,const QList<ParamInfo>& paramInfo);

    int TaskId(const QString& taskName);

public:
    QMap<int,QString> networkTaskId;
    QList<BatchCheckInPcuInfo> bciPcuInfo;
    QList<BatchCheckOutPcuInfo> bcoPcuInfo;
    QList<ParamInfo> paramInfo;
    ParamKeys paramKey;

    QString BatchCheckIn() const {return checkIn;}
    QString BatchCheckOut()const {return checkOut;}
    QString HeartbeatDetection()const{return heartbeatDetection;}
    QString MatchProcParamCollect()const{return procParamCollect;}
    QString MatchAlarmReport()const{return alaramReport;}

signals:
    void onCurrentTaskCompleted();

private slots:
    void onRequestCompleted(int taskId, bool success, const QString& error);
    void onNetworkError(int taskId, const QString& errorString);

private:
    NetworkManager* networkManager;
    QMap<int,QString> taskList;
    QHash<QString,int> tasks;


    const QString checkIn = "BatchCheckIn";
    const QString checkOut = "BatchCheckOut";
    const QString heartbeatDetection = "HeartbeatDetection";
    const QString procParamCollect = "MatchProcParamCollect";
    const QString alaramReport = "MatchAlarmReport";

};

#endif // TASKMANAGER_H
